package com.lhf.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 尐痞猫
 * @date2021-07-06 14:10
 */
public class DateUtil {

    public  static Date date_addDay(Date time){
        Date newTime=null;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long t = time.getTime();
        long newt = t+1000;
        String timeStr = format.format(newt);
        try {
            newTime = format.parse(timeStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return newTime;
    }

    public static  Date date_subDay(Date time){
        Date newTime=null;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long t = time.getTime();
        long newt = t-1000;
        String timeStr = format.format(newt);
        try {
            newTime = format.parse(timeStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return newTime;
    }
    public static  Date NowDate(){
        Date newdate  = null;
        Date date=new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long newt = date.getTime();
        String timeStr = format.format(newt);
        try {
            newdate = format.parse(timeStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return newdate;
    }
    public static  Date getEndTime(){
        Date newdate  = null;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date=new Date();
        SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
        long newt = date.getTime();
        String timeStr = format2.format(newt);

        String newTimeStr = timeStr+" 23:59:59";
        try {
            newdate = format.parse(newTimeStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return newdate;
    }


}
